from django.contrib import admin
from pub_app.models import *
# Register your models here.
# 首页列表设置
class ListClassAdmin(admin.ModelAdmin):
    list_display = ('list_name', 'tag', 'list_self', 'show', 'flag',)
    # exclude = ('click_times', 'discuss_times', 'focus_times', 'thumbs_up', 'thumbs_down', 'base_content', 'share_times', 'collection_times')
    # readonly_fields = ('sbeizhu',)
    # 自定义一个字段

    list_per_page = 18

    # 搜索框
    search_fields = ('list_name','list_self__list_name')
    # list_filter = ('status', 'news_class')
    # list_editable列表中可编辑字段
    # list_editable = ('status',)
    # 选中类别
    # filter_horizontal = ('news_class',)

class HomeDetailInline(admin.TabularInline):
    model = HomeDetail
    # readonly_fields = ("image_data", "con")
    extra = 0
    fields = ("list_name",'image','tag','show','flag','introduction')


class HomeFunctionAdmin(admin.ModelAdmin):
    list_display = ('home_name', 'tag', 'show',)
    list_per_page = 18
    inlines = [
        HomeDetailInline,
    ]

    # 搜索框
    search_fields = ('home_name',)


class CanDataDetailInline(admin.TabularInline):
    model = CanDataDetail
    # readonly_fields = ("image_data", "con")
    extra = 0
    fields = ('hymc', 'ccky', 'xjjj','yk')


class CanDataAdmin(admin.ModelAdmin):
    list_display = ('name',"flyl",'zqy','ccsz','djzj','kyzj','ywcsz','type')
    list_per_page = 18
    inlines = [
        CanDataDetailInline,
    ]

    # # 搜索框
    # search_fields = ('home_name',)


admin.site.register(ListClass, ListClassAdmin)
admin.site.register(HomeFunction, HomeFunctionAdmin)
admin.site.register(CanData, CanDataAdmin)